<?
        $results = array();
        require_once('../inc/statusfunc.php');
        if(isset($_POST['id']))
        {
            $row = $_POST;
			$results = SaveStatus($row);
			if($results === true){
				header("Location: index.php");
				die();
			}
		}	
        else{
                $row = GetStatus($_REQUEST['id']);
        }
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Edit user: <?=$row['first_name']?> <?=$row['last_name']?></title>
    <link rel="stylesheet" type="text/css" href="../inc/bootstrap.css">
    <style type="text/css">
        .error { color: red; }
        body { margin:20px; }
    </style>
</head>

<body>
                
        <dl class="error">
    		<? foreach ($results as $key => $value): ?>
    			<dt><?=$key?></dt>
    			<dd><?=$value?></dd>        		
    		<? endforeach; ?>
    	</dl>
        
        <form class="form-horizontal" method="post" action="">
            <input type="hidden" name="id" id="status_id" value="<?=$row['status_id']?>" />
            
            	<label for="updated_at">Updated at:</label>
                    <input type="datetime" name="updated_at" id="updated_at" value="<?=$row['updated_at']?>" />
                    
                <label for="statusname">Status name:</label>
                    <input type="text" name="statusname" id="statusname" value="<?=$row['statusname']?>" />

            <input class="btn btn-primary" type="submit" value="Save" />
        </form>
        
        <a href="index.php">Index</a>

</body>
</html>